//
//  NYGoodSubjectActionCell.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2018/1/4.
//  Copyright © 2018年 niuwaketang. All rights reserved.
//

#import "NYGoodSubjectActionCell.h"
@interface NYGoodSubjectActionCell ()
@property(nonatomic, strong) QMUIButton *seeAnalysisBtn;
@property(nonatomic, strong) QMUIButton *continueAnswerQuestionBtn;
@end
@implementation NYGoodSubjectActionCell
+ (CGFloat)heightForObject:(id)object identifier:(NSString *)identifier atIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView
{
        return __WGHeight(50);
}
- (BOOL)shouldUpdateCellWithObject:(NICellObject *)object atIndexPath:(NSIndexPath *)indexPath
{
        self.indexPath = indexPath;
        self.subjectModel = (NYSubjectModel *)object.userInfo;
        return YES;
}
- (void)setSubjectModel:(NYSubjectModel *)subjectModel
{
        _subjectModel = subjectModel;
        [self updateContent];
}
- (void)updateContent
{
        
}
- (void)setupView
{
        [super setupView];
        
        UIView *contentView = [[UIView alloc] init];
        [self.contentView addSubview:contentView];
        
        UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:@[self.seeAnalysisBtn,self.continueAnswerQuestionBtn]];
        stackView.axis = UILayoutConstraintAxisHorizontal;
        stackView.distribution = UIStackViewDistributionFillEqually;
        stackView.alignment = UIStackViewAlignmentFill;
        stackView.spacing = __WGWidth(1);
        stackView.qmui_borderPosition = QMUIBorderViewPositionTop;
        [contentView addSubview:stackView];
        
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = UIColorHex(0xE1E1E1);
        [stackView addSubview:lineView];
        
        [contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.left.right.equalTo(self.contentView);
                make.bottom.equalTo(self.contentView).priorityLow();
        }];
        
        [stackView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.left.right.bottom.equalTo(contentView);
                make.height.mas_equalTo(__WGHeight(50));
        }];
        
        [lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.center.equalTo(stackView);
                make.height.mas_equalTo(__WGHeight(20));
                make.width.mas_equalTo(__WGWidth(1));
        }];
}
- (void)setActionBlock:(NYGoodSubjectActionBlock)actionBlock
{
        @weakify(self);
        [self.seeAnalysisBtn jk_addActionHandler:^(NSInteger tag) {
                @strongify(self);
                if (actionBlock) {
                        actionBlock(self.subjectModel,NYGoodSubjectActionTypeSeeAnalysis);
                }
        }];
        
        [self.continueAnswerQuestionBtn jk_addActionHandler:^(NSInteger tag) {
                @strongify(self);
                if (actionBlock) {
                        actionBlock(self.subjectModel,NYGoodSubjectActionTypeContinueAnswer);
                }
        }];
}
- (QMUIButton *)seeAnalysisBtn
{
        if (_seeAnalysisBtn == nil) {
                _seeAnalysisBtn = [[QMUIButton alloc] qmui_initWithImage:[UIImage cha_kan_jie_xi] title:@"查看解析"];
                _seeAnalysisBtn.spacingBetweenImageAndTitle = __WGWidth(13);
                _seeAnalysisBtn.titleLabel.font = WGSystem14Font;
                [_seeAnalysisBtn setTitleColor:UIColorBlack forState:(UIControlStateNormal)];
        }
        return _seeAnalysisBtn;
}
- (QMUIButton *)continueAnswerQuestionBtn
{
        if (_continueAnswerQuestionBtn == nil) {
                _continueAnswerQuestionBtn = [[QMUIButton alloc] qmui_initWithImage:[UIImage ji_xu_da_ti] title:@"继续答题"];
                _continueAnswerQuestionBtn.spacingBetweenImageAndTitle = __WGWidth(13);
                _continueAnswerQuestionBtn.titleLabel.font = WGSystem14Font;
                [_continueAnswerQuestionBtn setTitleColor:UIColorBlack forState:(UIControlStateNormal)];
        }
        return _continueAnswerQuestionBtn;
}
@end
